package com.wzw.wx.api.controller;

import com.wzw.wx.api.service.OfficeTransService;
import org.jodconverter.core.util.AssertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("convert")
public class ConvertController {
    @Autowired
    private OfficeTransService transService;

    /**
     * 自用小工具 免费转换word-pdf、pdf-png
     * @param file 要转换的文件、后续可优化支持多个文件转换
     * @return 转换后文件地址
     */
    @RequestMapping("/local/office")
    public String transLocalOffice(@RequestParam("file") MultipartFile file) {
        if (file.isEmpty())
            AssertUtils.notNull(file, "请上传文件");

        return transService.transOfficeFile(file);
    }

}